<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>

	<head>
		<meta http-equiv="content-type" content="text/html;charset=UTF-8" />
		<script type="text/javascript" src="../../js/boot.js"></script>
		<title></title>
	</head>

	<body>
		<div id="dataForm">
			<table>
				<tr>
					<td> <label>原密码：</label> </td>
					<td> <input name="oldPassword" class="mini-password" required="true" /> </td>
				</tr>
				<tr>
					<td> <label>新密码：</label> </td>
					<td> <input name="loginPassword" class="mini-password" required="true" /> </td>
				</tr>
				<tr>
					<td> <label>确认密码：</label> </td>
					<td> <input name="loginPassword2" class="mini-password" required="true" /> </td>
				</tr>
			</table>
			<a class="mini-button" style="width:120px;" onclick="save()">修改密码</a>
		</div>
	</body>

	<script type="text/javascript">
		var userID = null;
		var obj = localStorage.getItem('user');
		if(obj) {
			var user = mini.decode(obj);
			userID = user.userID;
		} else {
			alert("用户不存在，请重新登录！");
		}

		miniInit();
		var pageForm = new mini.Form("#dataForm");

		/**
		 * 保存
		 */
		function save() {
			pageForm.validate();
			if(pageForm.isValid() == false) return;
			var data = pageForm.getData();
			if(data.loginPassword != data.loginPassword2) {
				alert("二次输入的新密码不一致！");
				return;
			}
			data.userID = userID;
			http.post("/user/changePassword.do", data, function(page) {
				if(page.success) {
					alert("修改成功！");
					window.top.location.href = ctx + "/page/login.html";
				}
			});
		}
	</script>

</html>